 cap clear
   
 ******* Demographics and employment status from SCE
 cap erase demo.dta
 cap erase emp.dta
 import excel ./FRBNY-SCE-Public-Microdata-Complete-13-16.xlsx, clear sheet("Data") cellrange(A2) first
 preserve
 keep userid date weight Q10_* Q11 Q12new DSAME
 save emp, replace
 restore
 keep userid Q32 Q33 Q34 Q35_1 Q36
 drop if Q32==.&Q33==.&Q34==.&Q35_1==.&Q36==.
 save demo, replace
 
 import excel ./FRBNY-SCE-Public-Microdata-Complete-17-19.xlsx, clear sheet("Data") cellrange(A2) first
 preserve
 keep userid date weight Q10_* Q11 Q12new DSAME
 append using ./emp
 save emp, replace
 restore
 keep userid Q32 Q33 Q34 Q35_1 Q36
 drop if Q32==.&Q33==.&Q34==.&Q35_1==.&Q36==.
 append using ./demo
 save demo, replace
 
 import excel ./frbny-sce-public-microdata-latest.xlsx, clear sheet("Data") cellrange(A2) first
 preserve
 keep userid date weight Q10_* Q11 Q12new DSAME
 append using ./emp
 save emp, replace
 restore
 keep userid Q32 Q33 Q34 Q35_1 Q36
 drop if Q32==.&Q33==.&Q34==.&Q35_1==.&Q36==.
 append using ./demo
 save demo, replace
 ren Q32 age
 replace age=. if age<16|age>100
 ren Q33 female
 replace female=0 if female==2
 ren Q34 hispanic
 replace hispanic=0 if hispanic==2
 ren Q35_1 white
 ren Q36 educ
 replace educ=. if educ==9
 save demo, replace
 
 * DSAME4 indicates whether the worker was employed by the same firm in the last four months
 use emp, clear
 cap drop DSAME4
 order userid date DSAME
 sort userid date
 forvalues i=1/3 {
 	by userid: gen date`i'=date[_n-`i']
	replace date`i'=12*(floor(date/100)-floor(date`i'/100))+mod(date,100)-mod(date`i',100)
	by userid: gen DSAME`i'=DSAME[_n-`i']
 }
 gen DSAME4=1 if DSAME<=1&date1>=4&date1!=.
 replace DSAME4=1 if DSAME<=1&date1==3&DSAME1<=1
 replace DSAME4=1 if DSAME<=1&date1<=2&DSAME1<=1&date2>=4&date2!=.
 replace DSAME4=1 if DSAME<=1&date1<=2&DSAME1<=1&date2==3&DSAME2<=1
 replace DSAME4=1 if DSAME<=1&date1==1&DSAME1<=1&date2==2&DSAME2<=1&date3>=4&date3!=.
 replace DSAME4=1 if DSAME<=1&date1==1&DSAME1<=1&date2==2&DSAME2<=1&date3==3&DSAME3<=1
 order userid date* DSAME*
 drop date1 date2 date3 DSAME1 DSAME2 DSAME3
 save emp, replace
 
 
 ******** Estimate the effects of rejected Offers on employed workers
 import excel ./sce-labor-microdata-public.xlsx, clear sheet("Data") cellrange(A2) first
 
 * demographics and employment status
 merge m:1 userid using ./demo, nogen keep(match master)
 merge 1:1 userid date using ./emp, nogen keep(match master)
 erase ./demo.dta
 erase ./emp.dta
 
 * wage offers
  gen accept=0 if nl1==0
  gen reject=0 if nl1==0
  gen woffer=. if nl1==0
  gen fulltime=. if nl1==0
  
  replace accept=1 if nl1==1&nl3_1==1
  replace reject=0 if nl1==1&nl3_1==1
  replace woffer=nl2a_1 if nl1==1&nl3_1==1
  replace fulltime=nl2b_1 if nl1==1&nl3_1==1
  
  replace accept=0 if nl1==1&nl3_1==3
  replace reject=1 if nl1==1&nl3_1==3
  replace woffer=nl2a_1 if nl1==1&nl3_1==3
  replace fulltime=nl2b_1 if nl1==1&nl3_1==3
  
  replace accept=1 if nl1==2&nl3_1==1&nl3_2>=3&nl3_2<=3  /*nl3_2>=2&nl3_2<=4*/
  replace reject=0 if nl1==2&nl3_1==1&nl3_2>=3&nl3_2<=3
  replace woffer=nl2a_1 if nl1==2&nl3_1==1&nl3_2>=3&nl3_2<=3
  replace fulltime=nl2b_1 if nl1==2&nl3_1==1&nl3_2>=3&nl3_2<=3
  
  replace accept=1 if nl1==2&nl3_2==1&nl3_1>=3&nl3_1<=3
  replace reject=0 if nl1==2&nl3_2==1&nl3_1>=3&nl3_1<=3
  replace woffer=nl2a_2 if nl1==2&nl3_2==1&nl3_1>=3&nl3_1<=3
  replace fulltime=nl2b_2 if nl1==2&nl3_2==1&nl3_1>=3&nl3_1<=3
  
  replace accept=0 if nl1==2&nl3_1==3&nl3_2==3
  replace reject=1 if nl1==2&nl3_1==3&nl3_2==3
  replace woffer=nl2a_1 if nl1==2&nl3_1==3&nl3_2==3&nl2a_1!=.&(nl2a_2==.|nl2a_2<=nl2a_1)  /*nl2a_1!=.&nl2a_2<=nl2a_1*/
  replace fulltime=nl2b_1 if nl1==2&nl3_1==3&nl3_2==3&nl2a_1!=.&(nl2a_2==.|nl2a_2<=nl2a_1)
  replace woffer=nl2a_2 if nl1==2&nl3_1==3&nl3_2==3&nl2a_2!=.&(nl2a_1==.|nl2a_2>nl2a_1)
  replace fulltime=nl2b_2 if nl1==2&nl3_1==3&nl3_2==3&nl2a_2!=.&(nl2a_1==.|nl2a_2>nl2a_1)
  
  replace accept=1 if nl1>=3&nl1!=.&nl3_1==1&nl3_2>=3&nl3_2<=3&nl3_3>=3&nl3_3<=3  /*nl3_2>=2&nl3_2<=4*/
  replace reject=0 if nl1>=3&nl1!=.&nl3_1==1&nl3_2>=3&nl3_2<=3&nl3_3>=3&nl3_3<=3
  replace woffer=nl2a_1 if nl1>=3&nl1!=.&nl3_1==1&nl3_2>=3&nl3_2<=3&nl3_3>=3&nl3_3<=3
  replace fulltime=nl2b_1 if nl1>=3&nl1!=.&nl3_1==1&nl3_2>=3&nl3_2<=3&nl3_3>=3&nl3_3<=3
  
  replace accept=1 if nl1>=3&nl1!=.&nl3_2==1&nl3_1>=3&nl3_1<=3&nl3_3>=3&nl3_3<=3
  replace reject=0 if nl1>=3&nl1!=.&nl3_2==1&nl3_1>=3&nl3_1<=3&nl3_3>=3&nl3_3<=3
  replace woffer=nl2a_2 if nl1>=3&nl1!=.&nl3_2==1&nl3_1>=3&nl3_1<=3&nl3_3>=3&nl3_3<=3
  replace fulltime=nl2b_2 if nl1>=3&nl1!=.&nl3_2==1&nl3_1>=3&nl3_1<=3&nl3_3>=3&nl3_3<=3
  
  replace accept=1 if nl1>=3&nl1!=.&nl3_3==1&nl3_2>=3&nl3_2<=3&nl3_1>=3&nl3_1<=3
  replace reject=0 if nl1>=3&nl1!=.&nl3_3==1&nl3_2>=3&nl3_2<=3&nl3_1>=3&nl3_1<=3
  replace woffer=nl2a_3 if nl1>=3&nl1!=.&nl3_3==1&nl3_2>=3&nl3_2<=3&nl3_1>=3&nl3_1<=3
  replace fulltime=nl2b_3 if nl1>=3&nl1!=.&nl3_3==1&nl3_2>=3&nl3_2<=3&nl3_1>=3&nl3_1<=3
  
  replace accept=0 if nl1>=3&nl1!=.&nl3_1==3&nl3_2==3&nl3_3==3
  replace reject=1 if nl1>=3&nl1!=.&nl3_1==3&nl3_2==3&nl3_3==3
  replace woffer=nl2a_1 if nl1>=3&nl1!=.&nl3_1==3&nl3_2==3&nl3_3==3&nl2a_1!=.&((nl2a_2==.&nl2a_3==.)|(nl2a_2<=nl2a_1&nl2a_3==.)|(nl2a_2==.&nl2a_3<=nl2a_1)|(nl2a_2<=nl2a_1&nl2a_3<=nl2a_1))
  replace fulltime=nl2b_1 if nl1>=3&nl1!=.&nl3_1==3&nl3_2==3&nl3_3==3&nl2a_1!=.&((nl2a_2==.&nl2a_3==.)|(nl2a_2<=nl2a_1&nl2a_3==.)|(nl2a_2==.&nl2a_3<=nl2a_1)|(nl2a_2<=nl2a_1&nl2a_3<=nl2a_1))
  replace woffer=nl2a_2 if nl1>=3&nl1!=.&nl3_1==3&nl3_2==3&nl3_3==3&nl2a_2!=.&((nl2a_1==.&nl2a_3==.)|(nl2a_2>nl2a_1&nl2a_3==.)|(nl2a_1==.&nl2a_3<=nl2a_2)|(nl2a_2>nl2a_1&nl2a_3<=nl2a_2))
  replace fulltime=nl2b_2 if nl1>=3&nl1!=.&nl3_1==3&nl3_2==3&nl3_3==3&nl2a_2!=.&((nl2a_1==.&nl2a_3==.)|(nl2a_2>nl2a_1&nl2a_3==.)|(nl2a_1==.&nl2a_3<=nl2a_2)|(nl2a_2>nl2a_1&nl2a_3<=nl2a_2))
  replace woffer=nl2a_3 if nl1>=3&nl1!=.&nl3_1==3&nl3_2==3&nl3_3==3&nl2a_3!=.&((nl2a_2==.&nl2a_1==.)|(nl2a_3>nl2a_2&nl2a_1==.)|(nl2a_2==.&nl2a_3>nl2a_1)|(nl2a_3>nl2a_1&nl2a_3>nl2a_2))
  replace fulltime=nl2b_3 if nl1>=3&nl1!=.&nl3_1==3&nl3_2==3&nl3_3==3&nl2a_3!=.&((nl2a_2==.&nl2a_1==.)|(nl2a_3>nl2a_2&nl2a_1==.)|(nl2a_2==.&nl2a_3>nl2a_1)|(nl2a_3>nl2a_1&nl2a_3>nl2a_2))
  
  egen max_offer=rowmax(nl2a_*)
  gen max_offer_fp=.
  forvalues i=1/3 {
  	replace max_offer_fp=nl2b_`i' if max_offer_fp==.&max_offer==nl2a_`i'
  }
  
  * reservation wages
  replace rw2a=rw2a*40*52 if rw2b==1
  replace rw2a=rw2a*52 if rw2b==2
  replace rw2a=rw2a*26 if rw2b==3
  replace rw2a=rw2a*12 if rw2b==4
  replace rw2a=. if rw2b==.&date<201703
 
 * wages and offers from the next period: 4 months later
 sort userid date
 foreach s of var l3 Q10_* Q12new accept reject woffer fulltime max_offer max_offer_fp date l1y l1m nl1 oo2f DSAME4 rw2a lmsat1 lmsat2 lmsat5 {
 	 by userid: gen `s'_n=`s'[_n+1] if (date[_n+1]-date==4)|(date[_n+1]-date==92)
 }
 
 * wages, matching probabilities and reservation wages 8 months later
 foreach s of var l3 oo2f rw2a lmsat1 lmsat2 lmsat5 {
 	by userid: gen `s'_nn=`s'_n[_n+1] if (date[_n+1]-date==4)|(date[_n+1]-date==92)
 }
 
  * outliers
  foreach s of var l3 l3_n l3_nn rw2a rw2a_n rw2a_nn oo2a oo2e2 woffer_n max_offer_n {
  	replace `s'=. if `s'<10000|`s'>500000
  }
  
 * inflation adjustment
 foreach s of var l3 l3_n l3_nn rw2a rw2a_n rw2a_nn oo2a oo2e2 woffer_n max_offer_n {
 	replace `s'=`s'*255.7/236.7 if floor(date/100)==2014
	replace `s'=`s'*255.7/237 if floor(date/100)==2015
	replace `s'=`s'*255.7/240 if floor(date/100)==2016
	replace `s'=`s'*255.7/245.1 if floor(date/100)==2017
	replace `s'=`s'*255.7/251.1 if floor(date/100)==2018
	replace `s'=`s'*255.7/258.8 if floor(date/100)==2020
	replace `s'=`s'*255.7/271 if floor(date/100)==2021
 }
  
  *log wages and other adjustments
  gen ly=log(l3)
  gen ly_n=log(l3_n)
  gen dy=ly_n-ly
  gen ly_nn=log(l3_nn)
  
  gen lyo=log(oo2a)
  
  gen lye=log(oo2e2)
  gen dye=lye-ly
  
  gen lrw=log(rw2a)
  gen lrw_n=log(rw2a_n)
  gen lrw_nn=log(rw2a_nn)
  gen drw=lrw_n-lrw
  
  gen lq=log(woffer_n)
  gen dq=lq-ly
  
  gen lq_max=log(max_offer_n)
  
  foreach s of var oo1_2 oo1_3 oo2e oo2f oo2f_n oo2f_nn {
  	replace `s'=`s'/100
  }
  
  gen dm=oo2f_n-oo2f
  
  gen tenure=(floor(date/100)-l1y)+(mod(date,100)-l1m)/12
  gen college=(educ>=5) if educ!=.
  
  * All salaries in $1000
  foreach s of var l3 l3_n l3_nn oo2a oo2e2 rw2a rw2a_n rw2a_nn woffer_n max_offer_n {
  	replace `s'=`s'/1000
  }
  
  * Figure 3
  preserve
  gen offer=100*(nl1_n>0) if nl1_n>=0&nl1_n!=.
  areg offer oo2e age female college ly, a(date) vce(cluster userid)
  sum oo2e [aw=weight] if offer!=.&oo2e>0,d
  gen oo2e_g=1 if oo2e>=0&oo2e<=0.1
  replace oo2e_g=2 if oo2e>0.1&oo2e<=0.2
  replace oo2e_g=3 if oo2e>0.2&oo2e<=0.3
  replace oo2e_g=4 if oo2e>0.3&oo2e<=0.4
  replace oo2e_g=5 if oo2e>0.4&oo2e<=0.5
  replace oo2e_g=6 if oo2e>0.5&oo2e<=0.6
  replace oo2e_g=7 if oo2e>0.6&oo2e<=0.7
  replace oo2e_g=8 if oo2e>0.7&oo2e<=0.8
  replace oo2e_g=9 if oo2e>0.8&oo2e<=0.9
  replace oo2e_g=10 if oo2e>0.9&oo2e<=1
  keep if oo2e_g!=.
  sum oo2e offer [aw=weight] if oo2e!=.&offer!=.
  collapse offer [aw=weight], by(oo2e_g)
  label define oo2e_l 1 "[0,10]" 2 "(10,20]" 3 "(20,30]" 4 "(30,40]" 5 "(40,50]" ///
  6 "(50,60]" 7 "(60,70]" 8 "(70,80]" 9 "(80,90]" 10 "(90,100]"
  label values oo2e_g oo2e_l
  tw (connected offer oo2e_g, lwidth(medthick) lcolor(black) mcolor(black)), plotr(m(b=0)) graphr(m(l+0 r+2)) ylab(0(10)60) xlab(1(1)10,valuelabel) ///
  ytitle("% with at least one offer in the next four months") ///
  xtitle("Expected chance of receiving at least one job offer from another firm" "in the next four months (%)")
  graph export ./Figure3.pdf, replace
  restore
  
  * sample selection
  gen temp1=0
  gen temp2=0
  forvalues i=1/3 {
  	replace temp1=temp1+1 if nl3_`i'==1|nl3_`i'==2
	replace temp2=temp2+1 if nl3_`i'==3
  }
  gen temp3=temp1+temp2
  forvalues i=1/3 {
  	egen tot`i'=total(temp`i')
  }
  replace tot1=tot1/tot3
  replace tot2=tot2/tot3
  sum tot*
  drop temp1 temp2 temp3 tot1 tot2 tot3
  
  sum accept_n [aw=weight] if weight!=.&Q10_1==1&Q12new==1&Q10_1_n&Q12new_n==1&dy!=.&(accept_n==1|reject_n==1|nl1_n==0)
  sum reject_n [aw=weight] if weight!=.&Q10_1==1&Q12new==1&Q10_1_n&Q12new_n==1&dy!=.&(accept_n==1|reject_n==1|nl1_n==0)
  
  keep if weight!=.&Q10_1==1&Q12new==1&Q10_1_n&Q12new_n==1&dy!=.
  keep if (DSAME4_n==1&(nl1_n==0|reject_n==1))|(DSAME4_n!=1&accept_n==1)
    
  * Table 1 and Table A1: descriptive statistics
  cap ssc install estout
  gen exp=.
  replace exp=age-16 if educ==1
  replace exp=age-18 if educ==2
  replace exp=age-19 if educ==3
  replace exp=age-20 if educ==4
  replace exp=age-22 if educ==5
  replace exp=age-24 if educ==6
  replace exp=age-27 if educ==7|educ==8
  * changes in job satisfaction
  gen dsat1=lmsat1_n-lmsat1
  gen dsat2=lmsat2_n-lmsat2
  gen dsat5=lmsat5_n-lmsat5
  
  local i=0
  foreach s of var age female college exp tenure l3 oo2e2 rw2a oo2a oo2e oo2f dy dm dsat5 {
  	local i=`i'+1
  	sum `s' [aw=weight] if accept_n==0&reject_n==0
	scalar b1_`i'=r(mean)
	scalar s1_`i'=r(sd)
	sum `s' [aw=weight] if reject_n==1
	scalar b2_`i'=r(mean)
	scalar s2_`i'=r(sd)
	reg `s' reject_n [aw=weight] if accept_n==0, vce(cluster userid)
	scalar b3_`i'=_b[reject_n]
	scalar s3_`i'=_se[reject_n]
  	sum `s' [aw=weight] if accept_n==1
	scalar b4_`i'=r(mean)
	scalar s4_`i'=r(sd)
	reg `s' accept_n [aw=weight] if reject_n==0, vce(cluster userid)
	scalar b5_`i'=_b[accept_n]
	scalar s5_`i'=_se[accept_n]
	reg `s' accept_n [aw=weight] if accept_n==1|reject_n==1, vce(cluster userid)
	scalar b6_`i'=_b[accept_n]
	scalar s6_`i'=_se[accept_n]
  }
  count if accept_n==0&reject_n==0
  scalar b1=r(N)
  count if reject_n==1
  scalar b2=r(N)
  count if accept_n==0
  scalar b3=r(N)
  count if accept_n==1
  scalar b4=r(N)
  count if reject_n==0
  scalar b5=r(N)
  count if accept_n==1|reject_n==1
  scalar b6=r(N)
  
  file open Table1 using Table1.tex, write replace
  file write Table1 "\begin{tabular} {lcccc} " _n ///
  "  \\  \hline\hline " _n ///
  " & Received zero offer & Rejected all offers & Difference  \\  \hline " _n
  file write Table1 "Age"                                           "&" %4.3f (b1_1)  "&"  %4.3f (b2_1)  "&"  %4.3f (b3_1) " \\ "  _n ///
                    "   "                                          "&(" %4.3f (s1_1) ")&(" %4.3f (s2_1) ")&(" %4.3f (s3_1) ") \\ "  _n ///
                    "Female"                                        "&" %4.3f (b1_2)  "&"  %4.3f (b2_2)  "&"  %4.3f (b3_2) " \\ "  _n ///
                    "   "                                          "&(" %4.3f (s1_2) ")&(" %4.3f (s2_2) ")&(" %4.3f (s3_2) ") \\ "  _n ///
				    "Bachelor's degree"                             "&" %4.3f (b1_3)  "&"  %4.3f (b2_3)  "&"  %4.3f (b3_3) " \\ "  _n ///
                    "   "                                          "&(" %4.3f (s1_3) ")&(" %4.3f (s2_3) ")&(" %4.3f (s3_3) ") \\ "  _n ///
					"Potential experience"                          "&" %4.3f (b1_4)  "&"  %4.3f (b2_4)  "&"  %4.3f (b3_4) " \\ "  _n ///
                    "   "                                          "&(" %4.3f (s1_4) ")&(" %4.3f (s2_4) ")&(" %4.3f (s3_4) ") \\ "  _n ///
					"Job tenure"                                    "&" %4.3f (b1_5)  "&"  %4.3f (b2_5)  "&"  %4.3f (b3_5) " \\ "  _n ///
                    "   "                                          "&(" %4.3f (s1_5) ")&(" %4.3f (s2_5) ")&(" %4.3f (s3_5) ") \\ "  _n ///
					"Salary (\$1000)"                   			"&" %4.3f (b1_6)  "&"  %4.3f (b2_6)  "&"  %4.3f (b3_6) " \\ "  _n ///
                    "   "                                          "&(" %4.3f (s1_6) ")&(" %4.3f (s2_6) ")&(" %4.3f (s3_6) ") \\ "  _n ///
					"Expected salary (\$1000)"           			"&" %4.3f (b1_7)  "&"  %4.3f (b2_7)  "&"  %4.3f (b3_7) " \\ "  _n ///
                    "   "                                          "&(" %4.3f (s1_7) ")&(" %4.3f (s2_7) ")&(" %4.3f (s3_7) ") \\ "  _n ///
					"Reservation salary (\$1000)"                   "&" %4.3f (b1_8)  "&"  %4.3f (b2_8)  "&"  %4.3f (b3_8) " \\ "  _n ///
                    "   "                                          "&(" %4.3f (s1_8) ")&(" %4.3f (s2_8) ")&(" %4.3f (s3_8) ") \\ "  _n ///
					"Expected salary offer (\$1000)"                "&" %4.3f (b1_9)  "&"  %4.3f (b2_9)  "&"  %4.3f (b3_9) " \\ "  _n ///
                    "   "                                          "&(" %4.3f (s1_9) ")&(" %4.3f (s2_9) ")&(" %4.3f (s3_9) ") \\ "  _n ///
					"Expected offer probability"                    "&" %4.3f (b1_10)  "&"  %4.3f (b2_10)  "&"  %4.3f (b3_10) " \\ "  _n ///
                    "   "                                          "&(" %4.3f (s1_10) ")&(" %4.3f (s2_10) ")&(" %4.3f (s3_10) ") \\ "  _n ///
					"Expected offer matching probability"           "&" %4.3f (b1_11)  "&"  %4.3f (b2_11)  "&"  %4.3f (b3_11) " \\ "  _n ///
                    "   "                                          "&(" %4.3f (s1_11) ")&(" %4.3f (s2_11) ")&(" %4.3f (s3_11) ") \\ "  _n ///
					"Change in log salary"                         " &" %4.3f (b1_12)  "&"  %4.3f (b2_12)  "&"  %4.3f (b3_12) " \\ "  _n ///
                    "   "                                          "&(" %4.3f (s1_12) ")&(" %4.3f (s2_12) ")&(" %4.3f (s3_12) ") \\ "  _n ///
					"Change in expected offer matching"             "&" %4.3f (b1_13)  "&"  %4.3f (b2_13)  "&"  %4.3f (b3_13) " \\ "  _n ///
                    "   probability"                               "&(" %4.3f (s1_13) ")&(" %4.3f (s2_13) ")&(" %4.3f (s3_13) ") \\ "  _n ///
					"Change in overall job satisfaction"		    "&" %4.3f (b1_14)  "&"  %4.3f (b2_14)  "&"  %4.3f (b3_14) " \\ "  _n ///
                    "   "                                          "&(" %4.3f (s1_14) ")&(" %4.3f (s2_14) ")&(" %4.3f (s3_14) ") \\ "  _n ///
                    "Observations"                                  "&" %4.0f (b1)     "&"  %4.0f (b2)     "&"  %4.0f (b3)     " \\ "  _n
  file write Table1 "\hline\hline \end{tabular}"
  file close Table1
  
  file open TableA1 using TableA1.tex, write replace
  file write TableA1 "\begin{tabular} {lcccc} " _n ///
  "  \\  \hline\hline " _n ///
  " & Accepted an offer & Accepted - zero  & Accepted - rejected \\  \hline " _n
  file write TableA1 "Age"                                          "&" %4.3f (b4_1)  "&"  %4.3f (b5_1)  "&"  %4.3f (b6_1) " \\ "  _n ///
                    "   "                                          "&(" %4.3f (s4_1) ")&(" %4.3f (s5_1) ")&(" %4.3f (s6_1) ") \\ "  _n ///
                    "Female"                                        "&" %4.3f (b4_2)  "&"  %4.3f (b5_2)  "&"  %4.3f (b6_2) " \\ "  _n ///
                    "   "                                          "&(" %4.3f (s4_2) ")&(" %4.3f (s5_2) ")&(" %4.3f (s6_2) ") \\ "  _n ///
				    "Bachelor's degree"                             "&" %4.3f (b4_3)  "&"  %4.3f (b5_3)  "&"  %4.3f (b6_3) " \\ "  _n ///
                    "   "                                          "&(" %4.3f (s4_3) ")&(" %4.3f (s5_3) ")&(" %4.3f (s6_3) ") \\ "  _n ///
					"Potential experience"                          "&" %4.3f (b4_4)  "&"  %4.3f (b5_4)  "&"  %4.3f (b6_4) " \\ "  _n ///
                    "   "                                          "&(" %4.3f (s4_4) ")&(" %4.3f (s5_4) ")&(" %4.3f (s6_4) ") \\ "  _n ///
					"Job tenure"                                    "&" %4.3f (b4_5)  "&"  %4.3f (b5_5)  "&"  %4.3f (b6_5) " \\ "  _n ///
                    "   "                                          "&(" %4.3f (s4_5) ")&(" %4.3f (s5_5) ")&(" %4.3f (s6_5) ") \\ "  _n ///
					"Salary (\$1000)"                    			"&" %4.3f (b4_6)  "&"  %4.3f (b5_6)  "&"  %4.3f (b6_6) " \\ "  _n ///
                    "   "                                          "&(" %4.3f (s4_6) ")&(" %4.3f (s5_6) ")&(" %4.3f (s6_6) ") \\ "  _n ///
					"Expected salary (\$1000)"           			"&" %4.3f (b4_7)  "&"  %4.3f (b5_7)  "&"  %4.3f (b6_7) " \\ "  _n ///
                    "   "                                          "&(" %4.3f (s4_7) ")&(" %4.3f (s5_7) ")&(" %4.3f (s6_7) ") \\ "  _n ///
					"Reservation salary (\$1000)"                   "&" %4.3f (b4_8)  "&"  %4.3f (b5_8)  "&"  %4.3f (b6_8) " \\ "  _n ///
                    "   "                                          "&(" %4.3f (s4_8) ")&(" %4.3f (s5_8) ")&(" %4.3f (s6_8) ") \\ "  _n ///
					"Expected salary offer (\$1000)"                "&" %4.3f (b4_9)  "&"  %4.3f (b5_9)  "&"  %4.3f (b6_9) " \\ "  _n ///
                    "   "                                          "&(" %4.3f (s4_9) ")&(" %4.3f (s5_9) ")&(" %4.3f (s6_9) ") \\ "  _n ///
					"Expected offer probability"                 	"&" %4.3f (b4_10)  "&"  %4.3f (b5_10)  "&"  %4.3f (b6_10) " \\ "  _n ///
                    "   "                                          "&(" %4.3f (s4_10) ")&(" %4.3f (s5_10) ")&(" %4.3f (s6_10) ") \\ "  _n ///
					"Expected offer matching probability"           "&" %4.3f (b4_11)  "&"  %4.3f (b5_11)  "&"  %4.3f (b6_11) " \\ "  _n ///
                    "   "                                          "&(" %4.3f (s4_11) ")&(" %4.3f (s5_11) ")&(" %4.3f (s6_11) ") \\ "  _n ///
					"Change in log salary"                         " &" %4.3f (b4_12)  "&"  %4.3f (b5_12)  "&"  %4.3f (b6_12) " \\ "  _n ///
                    "   "                                          "&(" %4.3f (s4_12) ")&(" %4.3f (s5_12) ")&(" %4.3f (s6_12) ") \\ "  _n ///
					"Change in expected offer matching"             "&" %4.3f (b4_13)  "&"  %4.3f (b5_13)  "&"  %4.3f (b6_13) " \\ "  _n ///
                    "   probability"                               "&(" %4.3f (s4_13) ")&(" %4.3f (s5_13) ")&(" %4.3f (s6_13) ") \\ "  _n ///
					"Change in overall job satisfaction"            "&" %4.3f (b4_14)  "&"  %4.3f (b5_14)  "&"  %4.3f (b6_14) " \\ "  _n ///
                    "   "                                          "&(" %4.3f (s4_14) ")&(" %4.3f (s5_14) ")&(" %4.3f (s6_14) ") \\ "  _n ///
                    "Observations"                                  "&" %4.0f (b4)     "&"  %4.0f (b5)     "&"  %4.0f (b6)     " \\ "  _n
  file write TableA1 "\hline\hline \end{tabular}"
  file close TableA1
  scalar drop _all
  
  * Figures 1, A1 and A2
  tab lmsat5 reject_n if accept_n==0, chi2
  tab lmsat1 reject_n if accept_n==0, chi2
  tab lmsat2 reject_n if accept_n==0, chi2
  
  preserve
  ren lmsat5 lmsat
  keep if accept_n==0&lmsat>=1&lmsat<=5
  collapse (sum) weight, by(reject_n lmsat)
  bysort reject_n: egen tot=total(weight)
  replace weight=100*weight/tot
  graph bar weight,o(lmsat,gap(1)) o(reject_n, relabel(1 "Received zero offer" 2 "Rejected all offers")) ytitle("Share (%)") ylab(0(10)50) bar(1,color(black)) bar(2,color(black)) ///
  text(50 10 "1=Very dissatisfied" 50 42 "2=Somewhat dissatisfied" 50 80 "3=Neither dissatisfied nor satisfied" 48 12 "4=Somewhat satisfied" 48 37 "5=Very satisfied")
  graph export ./Figure1.pdf, replace
  restore
  
  preserve
  ren lmsat1 lmsat
  keep if accept_n==0&lmsat>=1&lmsat<=5
  collapse (sum) weight, by(reject_n lmsat)
  bysort reject_n: egen tot=total(weight)
  replace weight=100*weight/tot
  graph bar weight,o(lmsat,gap(1)) o(reject_n, relabel(1 "Received zero offer" 2 "Rejected all offers")) ytitle("Share (%)") ylab(0(10)50) bar(1,color(black)) bar(2,color(black)) ///
  text(50 10 "1=Very dissatisfied" 50 42 "2=Somewhat dissatisfied" 50 80 "3=Neither dissatisfied nor satisfied" 48 12 "4=Somewhat satisfied" 48 37 "5=Very satisfied")
  graph export ./FigureA1.pdf, replace
  restore
  
  preserve
  ren lmsat2 lmsat
  keep if accept_n==0&lmsat>=1&lmsat<=5
  collapse (sum) weight, by(reject_n lmsat)
  bysort reject_n: egen tot=total(weight)
  replace weight=100*weight/tot
  graph bar weight,o(lmsat,gap(1)) o(reject_n, relabel(1 "Received zero offer" 2 "Rejected all offers")) ytitle("Share (%)") ylab(0(10)50) bar(1,color(black)) bar(2,color(black)) ///
  text(50 10 "1=Very dissatisfied" 50 42 "2=Somewhat dissatisfied" 50 80 "3=Neither dissatisfied nor satisfied" 48 12 "4=Somewhat satisfied" 48 37 "5=Very satisfied")
  graph export ./FigureA2.pdf, replace
  restore
 
  * Figures 2 and A3
  gen dr=lq-lrw
  tw (kdensity dq [aw=weight] if reject_n==1, lwidth(medthick) lcolor(black))||(kdensity dr [aw=weight] if reject_n==1, lpattern(dash) lwidth(medthick) lcolor(black)), ///
  plotr(m(0)) legend(lab(1 "... log salary") lab(2 "... log reservation salary") ring(0) c(1))  xline(0) ///
  xtitle("Log rejected salary minus ... ") ytitle("Density")
  graph export ./Figure2.pdf, replace
  sum dq [aw=weight] if reject_n==1, d
  sum dr [aw=weight] if reject_n==1, d
  
  tw (kdensity dq [aw=weight] if accept_n==1,lwidth(medthick) lcolor(black))||(kdensity dr [aw=weight] if accept_n==1, lpattern(dash) lwidth(medthick) lcolor(black)), ///
  plotr(m(0)) legend(lab(1 "... log salary") lab(2 "... log reservation salary") ring(0) c(1))  xline(0) ///
  xtitle("Log accepted salary minus ... ") ytitle("Density")
  graph export ./FigureA3.pdf, replace
  sum dq [aw=weight] if accept_n==1, d
  sum dr [aw=weight] if accept_n==1, d
  
  * Table 5: both rejected and accepted offers
  replace exp=exp/10
  replace tenure=tenure/10
  label variable exp "Potential experience/10"
  label variable tenure "Tenure/10"
  label variable female "Female"
  label variable college "Bachelor's degree"
  label variable oo2e "Expected offer probability"
  label variable oo2f "Expected offer matching probability"
  label variable dye "Expected change in log salary"
  label variable dy "Change in log salary"
  label variable drw "Change in log reservation salary"
  label variable dm "Change in expected offer matching probability"
  label variable ly "Log salary"
  label variable lrw "Log reservation salary"
  label variable lye "Log expected salary"
  label variable lyo "Log expected salary offer"
  label variable reject_n "Rejected all offers"
  label variable accept_n "Accepted an offer"
  
  areg dy reject_n accept_n female college exp tenure dye oo2e lrw ly [aw=weight], a(date) vce(cluster userid)
  eststo a1
  count if e(sample)==1&accept_n==1
  scalar accept1=r(N)
  count if e(sample)==1&reject_n==1
  scalar reject1=r(N)
  areg dm reject_n accept_n female college exp tenure dye oo2e lrw ly oo2f [aw=weight], a(date) vce(cluster userid)
  eststo a2
  count if e(sample)==1&accept_n==1
  scalar accept2=r(N)
  count if e(sample)==1&reject_n==1
  scalar reject2=r(N)
  areg dsat5 reject_n accept_n female college exp tenure dye oo2e lrw ly i.lmsat5 [aw=weight], a(date) vce(cluster userid)
  eststo a3
  count if e(sample)==1&accept_n==1
  scalar accept3=r(N)
  count if e(sample)==1&reject_n==1
  scalar reject3=r(N)
  areg dsat1 reject_n accept_n female college exp tenure dye oo2e lrw ly i.lmsat1 [aw=weight], a(date) vce(cluster userid)
  eststo a4
  count if e(sample)==1&accept_n==1
  scalar accept4=r(N)
  count if e(sample)==1&reject_n==1
  scalar reject4=r(N)
  areg dsat2 reject_n accept_n female college exp tenure dye oo2e lrw ly i.lmsat2 [aw=weight], a(date) vce(cluster userid)
  eststo a5
  count if e(sample)==1&accept_n==1
  scalar accept5=r(N)
  count if e(sample)==1&reject_n==1
  scalar reject5=r(N)
  areg drw reject_n accept_n female college exp tenure dye oo2e lrw ly [aw=weight], a(date) vce(cluster userid)
  eststo a6
  count if e(sample)==1&accept_n==1
  scalar accept6=r(N)
  count if e(sample)==1&reject_n==1
  scalar reject6=r(N)

  esttab a* using ./Table5.tex, cells(b(fmt(%9.3f)) se(par fmt(%9.3f))) stats(N,fmt(%9.0f)) label replace
  eststo clear
  
  file open Table5A using Table5A.tex, write replace
  file write Table5A "\begin{tabular} {lcccccc} " _n
  file write Table5A "Rejected all offers"	"&" %4.0f (reject1)  "&" %4.0f (reject2)  "&" %4.0f (reject3)  "&" %4.0f (reject4)  "&" %4.0f (reject5)  "&" %4.0f (reject6) " \\ "  _n ///
					  "Accepted an offer"	"&" %4.0f (accept1)  "&" %4.0f (accept2)  "&" %4.0f (accept3)  "&" %4.0f (accept4)  "&" %4.0f (accept5)  "&" %4.0f (accept6) " \\ "  _n
  file write Table5A "\hline\hline \end{tabular}"
  file close Table5A
  scalar drop _all
    
  * Tables 2, 3, A2: main results
  keep if accept_n==0
  
  areg dy reject_n female college exp tenure [aw=weight], a(date) vce(cluster userid)
  eststo a1
  areg dy reject_n female college exp tenure dye [aw=weight], a(date) vce(cluster userid)
  eststo a2
  areg dy reject_n female college exp tenure dye oo2e lrw ly [aw=weight], a(date) vce(cluster userid)
  eststo a3
  areg dy reject_n female college exp tenure dye oo2e lrw lyo [aw=weight], a(date) vce(cluster userid)
  eststo a4
  areg dy reject_n female college exp tenure dye oo2e lrw ly [aw=weight] if e(sample)==1, a(date) vce(cluster userid)
  eststo a5
  esttab a* using ./Table2.tex, cells(b(fmt(%9.3f)) se(par fmt(%9.3f))) stats(N,fmt(%9.0f)) label replace
  eststo clear
       
  areg dm reject_n female college exp tenure [aw=weight], a(date) vce(cluster userid)
  eststo a1
  areg dm reject_n female college exp tenure dye oo2e lrw ly oo2f [aw=weight], a(date) vce(cluster userid)
  eststo a2
  areg dsat5 reject_n female college exp tenure [aw=weight], a(date) vce(cluster userid)
  eststo a3
  areg dsat5 reject_n female college exp tenure dye oo2e lrw ly i.lmsat5 [aw=weight], a(date) vce(cluster userid)
  eststo a4
  esttab a* using ./Table3.tex, cells(b(fmt(%9.3f)) se(par fmt(%9.3f))) stats(N,fmt(%9.0f)) label replace
  eststo clear
  
  areg dsat1 reject_n female college exp tenure [aw=weight], a(date) vce(cluster userid)
  eststo a1
  areg dsat1 reject_n female college exp tenure dye oo2e lrw ly i.lmsat1 [aw=weight], a(date) vce(cluster userid)
  eststo a2
  areg dsat2 reject_n female college exp tenure [aw=weight], a(date) vce(cluster userid)
  eststo a3
  areg dsat2 reject_n female college exp tenure dye oo2e lrw ly i.lmsat2 [aw=weight], a(date) vce(cluster userid)
  eststo a4
  areg drw reject_n female college exp tenure [aw=weight], a(date) vce(cluster userid)
  eststo a5
  areg drw reject_n female college exp tenure dye oo2e lrw ly [aw=weight], a(date) vce(cluster userid)
  eststo a6
  esttab a* using ./TableA2.tex, cells(b(fmt(%9.3f)) se(par fmt(%9.3f))) stats(N,fmt(%9.0f)) label replace
  eststo clear
      
  * Table 4: Robustness and heterogeneity
  sort userid date
  by userid: gen num=_n
  gen samp1=1 if num==1
  gen samp2=1 if (100*l1y_n+l1m_n<date)&l1y_n==l1y&l1m_n==l1m
  gen samp3=1 if nl1==0
  gen samp4=1 if date<=201911
  gen samp5=1 if college==0
  gen samp6=1 if college==1
  xtile temp=ly [aw=weight],n(3)
  gen samp7=1 if temp==1
  gen samp8=1 if temp==2
  gen samp9=1 if temp==3
  drop temp
  gen samp10=1 if tenure<=0.5
  gen samp11=1 if tenure>0.5&tenure!=.
  gen samp12=1 if oo2f<=0.3
  gen samp13=1 if oo2f>0.3&oo2f!=.
  forvalues i=1/13 {
  	areg dy reject_n female college exp tenure dye oo2e lrw ly [aw=weight] if samp`i'==1, a(date) vce(cluster userid)
	scalar b1_`i'=_b[reject_n]
	scalar s1_`i'=_se[reject_n]
	count if e(sample)==1&reject_n==1
	scalar n1_`i'=r(N)
	areg dm reject_n female college exp tenure dye oo2e lrw ly oo2f [aw=weight] if samp`i'==1, a(date) vce(cluster userid)
	scalar b2_`i'=_b[reject_n]
	scalar s2_`i'=_se[reject_n]
	count if e(sample)==1&reject_n==1
	scalar n2_`i'=r(N)
	areg dsat5 reject_n female college exp tenure dye oo2e lrw ly i.lmsat5 [aw=weight] if samp`i'==1, a(date) vce(cluster userid)
    scalar b3_`i'=_b[reject_n]
	scalar s3_`i'=_se[reject_n]
	count if e(sample)==1&reject_n==1
	scalar n3_`i'=r(N)
  }
  * more controls: job search activity
  local i=14
  areg dy reject_n female college exp tenure dye oo2e lrw ly i.js6 [aw=weight], a(date) vce(cluster userid)
  scalar b1_`i'=_b[reject_n]
  scalar s1_`i'=_se[reject_n]
  count if e(sample)==1&reject_n==1
  scalar n1_`i'=r(N)
  areg dm reject_n female college exp tenure dye oo2e lrw ly oo2f i.js6 [aw=weight], a(date) vce(cluster userid)
  scalar b2_`i'=_b[reject_n]
  scalar s2_`i'=_se[reject_n]
  count if e(sample)==1&reject_n==1
  scalar n2_`i'=r(N)
  areg dsat5 reject_n female college exp tenure dye oo2e lrw ly i.lmsat5 i.js6 [aw=weight], a(date) vce(cluster userid)
  scalar b3_`i'=_b[reject_n]
  scalar s3_`i'=_se[reject_n]
  count if e(sample)==1&reject_n==1
  scalar n3_`i'=r(N)
  * 8 months apart
  local i=15
  gen dyn=ly_nn-ly
  gen dmn=oo2f_nn-oo2f
  gen dsn=lmsat5_nn-lmsat5
  areg dyn reject_n female college exp tenure dye oo2e lrw ly [aw=weight], a(date) vce(cluster userid)
  scalar b1_`i'=_b[reject_n]
  scalar s1_`i'=_se[reject_n]
  count if e(sample)==1&reject_n==1
  scalar n1_`i'=r(N)
  areg dmn reject_n female college exp tenure dye oo2e lrw ly oo2f [aw=weight], a(date) vce(cluster userid)
  scalar b2_`i'=_b[reject_n]
  scalar s2_`i'=_se[reject_n]
  count if e(sample)==1&reject_n==1
  scalar n2_`i'=r(N)
  areg dsn reject_n female college exp tenure dye oo2e lrw ly i.lmsat5 [aw=weight], a(date) vce(cluster userid)
  scalar b3_`i'=_b[reject_n]
  scalar s3_`i'=_se[reject_n]
  count if e(sample)==1&reject_n==1
  scalar n3_`i'=r(N)
  
  file open Table4 using Table4.tex, write replace
  file write Table4 "\begin{tabular} {lccccccccc} " _n ///
  "  \\  \hline\hline " _n ///
  " & est & std & rej & est & std & rej & est & std & rej  \\  \hline " _n
  file write Table4 "First observation of each worker"	"&" %4.3f (b1_1)  "&" %4.3f (s1_1)  "&" %3.0f (n1_1)  "&" %4.3f (b2_1)  "&" %4.3f (s2_1)  "&" %3.0f (n2_1)  "&" %4.3f (b3_1)  "&" %4.3f (s3_1)  "&" %3.0f (n3_1) " \\ "  _n ///
                    "Same job starting month and year"	"&" %4.3f (b1_2)  "&" %4.3f (s1_2)  "&" %3.0f (n1_2)  "&" %4.3f (b2_2)  "&" %4.3f (s2_2)  "&" %3.0f (n2_2)  "&" %4.3f (b3_2)  "&" %4.3f (s3_2)  "&" %3.0f (n3_2) " \\ "  _n ///
					"No offer in the last 4 months"		"&" %4.3f (b1_3)  "&" %4.3f (s1_3)  "&" %3.0f (n1_3)  "&" %4.3f (b2_3)  "&" %4.3f (s2_3)  "&" %3.0f (n2_3)  "&" %4.3f (b3_3)  "&" %4.3f (s3_3)  "&" %3.0f (n3_3) " \\ "  _n ///
					"Before COVID"						"&" %4.3f (b1_4)  "&" %4.3f (s1_4)  "&" %3.0f (n1_4)  "&" %4.3f (b2_4)  "&" %4.3f (s2_4)  "&" %3.0f (n2_4)  "&" %4.3f (b3_4)  "&" %4.3f (s3_4)  "&" %3.0f (n3_4) " \\ "  _n ///
					"Bachelor's degree: No"				"&" %4.3f (b1_5)  "&" %4.3f (s1_5)  "&" %3.0f (n1_5)  "&" %4.3f (b2_5)  "&" %4.3f (s2_5)  "&" %3.0f (n2_5)  "&" %4.3f (b3_5)  "&" %4.3f (s3_5)  "&" %3.0f (n3_5) " \\ "  _n ///
					"Bachelor's degree: Yes"			"&" %4.3f (b1_6)  "&" %4.3f (s1_6)  "&" %3.0f (n1_6)  "&" %4.3f (b2_6)  "&" %4.3f (s2_6)  "&" %3.0f (n2_6)  "&" %4.3f (b3_6)  "&" %4.3f (s3_6)  "&" %3.0f (n3_6) " \\ "  _n ///
					"Salary: 1st tercile"				"&" %4.3f (b1_7)  "&" %4.3f (s1_7)  "&" %3.0f (n1_7)  "&" %4.3f (b2_7)  "&" %4.3f (s2_7)  "&" %3.0f (n2_7)  "&" %4.3f (b3_7)  "&" %4.3f (s3_7)  "&" %3.0f (n3_7) " \\ "  _n ///
					"Salary: 2nd tercile"				"&" %4.3f (b1_8)  "&" %4.3f (s1_8)  "&" %3.0f (n1_8)  "&" %4.3f (b2_8)  "&" %4.3f (s2_8)  "&" %3.0f (n2_8)  "&" %4.3f (b3_8)  "&" %4.3f (s3_8)  "&" %3.0f (n3_8) " \\ "  _n ///
					"Salary: 3rd tercile"				"&" %4.3f (b1_9)  "&" %4.3f (s1_9)  "&" %3.0f (n1_9)  "&" %4.3f (b2_9)  "&" %4.3f (s2_9)  "&" %3.0f (n2_9)  "&" %4.3f (b3_9)  "&" %4.3f (s3_9)  "&" %3.0f (n3_9) " \\ "  _n ///
					"Tenure: less than 5 years"			"&" %4.3f (b1_10) "&" %4.3f (s1_10) "&" %3.0f (n1_10) "&" %4.3f (b2_10) "&" %4.3f (s2_10) "&" %3.0f (n2_10) "&" %4.3f (b3_10) "&" %4.3f (s3_10) "&" %3.0f (n3_10) " \\ "  _n ///
					"Tenure: more than 5 years"			"&" %4.3f (b1_11) "&" %4.3f (s1_11) "&" %3.0f (n1_11) "&" %4.3f (b2_11) "&" %4.3f (s2_11) "&" %3.0f (n2_11) "&" %4.3f (b3_11) "&" %4.3f (s3_11) "&" %3.0f (n3_11) " \\ "  _n ///
					"Matching prob: less than 0.3"		"&" %4.3f (b1_12) "&" %4.3f (s1_12) "&" %3.0f (n1_12) "&" %4.3f (b2_12) "&" %4.3f (s2_12) "&" %3.0f (n2_12) "&" %4.3f (b3_12) "&" %4.3f (s3_12) "&" %3.0f (n3_12) " \\ "  _n ///
					"Matching prob: more than 0.3"		"&" %4.3f (b1_13) "&" %4.3f (s1_13) "&" %3.0f (n1_13) "&" %4.3f (b2_13) "&" %4.3f (s2_13) "&" %3.0f (n2_13) "&" %4.3f (b3_13) "&" %4.3f (s3_13) "&" %3.0f (n3_13) " \\ "  _n ///
					"Job search activity"				"&" %4.3f (b1_14) "&" %4.3f (s1_14) "&" %3.0f (n1_14) "&" %4.3f (b2_14) "&" %4.3f (s2_14) "&" %3.0f (n2_14) "&" %4.3f (b3_14) "&" %4.3f (s3_14) "&" %3.0f (n3_14) " \\ "  _n ///
					"8 months"							"&" %4.3f (b1_15) "&" %4.3f (s1_15) "&" %3.0f (n1_15) "&" %4.3f (b2_15) "&" %4.3f (s2_15) "&" %3.0f (n2_15) "&" %4.3f (b3_15) "&" %4.3f (s3_15) "&" %3.0f (n3_15) " \\ "  _n
  file write Table4 "\hline\hline \end{tabular}"
  file close Table4
  scalar drop _all
	
  *** Table A3 interactions
  gen reject_college=reject_n*college
  gen reject_ly=reject_n*ly
  gen reject_tenure=reject_n*tenure
  gen reject_oo2f=reject_n*oo2f
  areg dy reject_n female college exp tenure dye oo2e lrw ly reject_college [aw=weight], a(date) vce(cluster userid)
  eststo a1
  areg dy reject_n female college exp tenure dye oo2e lrw ly reject_ly [aw=weight], a(date) vce(cluster userid)
  eststo a2
  areg dy reject_n female college exp tenure dye oo2e lrw ly reject_tenure [aw=weight], a(date) vce(cluster userid)
  eststo a3
  areg dy reject_n female college exp tenure dye oo2e lrw ly oo2f reject_oo2f [aw=weight], a(date) vce(cluster userid)
  eststo a4
  esttab a* using ./TableA3.tex, cells(b(fmt(%9.3f)) se(par fmt(%9.3f))) stats(N,fmt(%9.0f)) label replace
  eststo clear
  
  *** Table 6: rejected a high-salary offer
  cap drop reject_low reject_hig
  gen reject_low=0
  gen reject_hig=0
  replace reject_low=1 if reject_n==1&dq<=0
  replace reject_hig=1 if reject_n==1&dq>0&dq!=.
  label variable reject_low "Reject low"
  label variable reject_hig "Reject high"
  areg dy reject_hig reject_low female college exp tenure dye oo2e lrw ly [aw=weight], a(date) vce(cluster userid)
  eststo a1
  count if e(sample)==1&reject_hig==1
  scalar accept1=r(N)
  count if e(sample)==1&reject_low==1
  scalar reject1=r(N)
  areg dm reject_hig reject_low female college exp tenure dye oo2e lrw ly oo2f [aw=weight], a(date) vce(cluster userid)
  eststo a3
  count if e(sample)==1&reject_hig==1
  scalar accept3=r(N)
  count if e(sample)==1&reject_low==1
  scalar reject3=r(N)
  areg dsat5 reject_hig reject_low female college exp tenure dye oo2e lrw ly i.lmsat1 [aw=weight], a(date) vce(cluster userid)
  eststo a5
  count if e(sample)==1&reject_hig==1
  scalar accept5=r(N)
  count if e(sample)==1&reject_low==1
  scalar reject5=r(N)
  
  cap drop reject_low reject_hig
  gen reject_low=0
  gen reject_hig=0
  replace reject_low=1 if reject_n==1&lq<lyo&lyo!=.
  replace reject_hig=1 if reject_n==1&lq>=lyo&lq!=.
  label variable reject_low "Reject low"
  label variable reject_hig "Reject high"
  areg dy reject_hig reject_low female college exp tenure dye oo2e lrw ly [aw=weight], a(date) vce(cluster userid)
  eststo a2
  count if e(sample)==1&reject_hig==1
  scalar accept2=r(N)
  count if e(sample)==1&reject_low==1
  scalar reject2=r(N)
  areg dm reject_hig reject_low female college exp tenure dye oo2e lrw ly oo2f [aw=weight], a(date) vce(cluster userid)
  eststo a4
  count if e(sample)==1&reject_hig==1
  scalar accept4=r(N)
  count if e(sample)==1&reject_low==1
  scalar reject4=r(N)
  areg dsat5 reject_hig reject_low female college exp tenure dye oo2e lrw ly i.lmsat1 [aw=weight], a(date) vce(cluster userid)
  eststo a6
  count if e(sample)==1&reject_hig==1
  scalar accept6=r(N)
  count if e(sample)==1&reject_low==1
  scalar reject6=r(N)
  esttab a1 a2 a3 a4 a5 a6 using ./Table6.tex, cells(b(fmt(%9.3f)) se(par fmt(%9.3f))) stats(N,fmt(%9.0f)) label replace
  eststo clear
  
  file open Table6A using Table6A.tex, write replace
  file write Table6A "\begin{tabular} {lcccccc} " _n
  file write Table6A "Reject high"	"&" %4.0f (accept1)  "&" %4.0f (accept2)  "&" %4.0f (accept3)  "&" %4.0f (accept4)  "&" %4.0f (accept5)  "&" %4.0f (accept6) " \\ "  _n ///
					 "Reject low"	"&" %4.0f (reject1)  "&" %4.0f (reject2)  "&" %4.0f (reject3)  "&" %4.0f (reject4)  "&" %4.0f (reject5)  "&" %4.0f (reject6) " \\ "  _n
  file write Table6A "\hline\hline \end{tabular}"
  file close Table6A
  scalar drop _all
